import { Component } from '@angular/core';
import Store from "@app/shared/Store";
import {FormsModule} from "@angular/forms";
import {NgFor, NgForOf, NgIf} from "@angular/common";
import { Subscription} from "rxjs";
import {CheckRecordService} from "@app/shared/service/check-record.service";

@Component({
  selector: 'app-product-record',
  standalone: true,
  imports: [
    FormsModule,
    NgIf,
    NgForOf
  ],
  templateUrl: './product-record.component.html',
  styleUrl: './product-record.component.css'
})
export class ProductRecordComponent {
  subscribe: Subscription;

  constructor(checkRecord: CheckRecordService) {
    this.subscribe = checkRecord.CheckRecord$.subscribe((product:Product)=>{
      Store.recordHistoryMap[product.name]++;
    })
  }

  protected readonly Store = Store;
  protected readonly Object = Object;
  //销毁时
  ngOnDestroy(): void {
    this.subscribe.unsubscribe();
  }
}
